package com.itheima.map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Demo1 {
    public static void main(String[] args) {
        HashMap<String, String> map = new HashMap<>();
        map.put("杨过", "小龙女");
        map.put("郭靖", "黄蓉");
        map.put("张无忌", "周芷若");
        //
        map.put("张无忌", "赵敏");
        map.remove("杨过");
        map.containsKey("张无忌");
        map.containsKey("尹建平");
        map.containsValue("灭绝师太");
        System.out.println(map.size());
        System.out.println(map.isEmpty());
        // map.clear();
//遍历map-------获取键值的方法
        Set<String> set = map.keySet();
        for (String s : set) {
            String volue = map.get(s);
            System.out.println(s + "=======" + volue);
        }
        System.out.println("===============");
        //遍历map获取--------键值对的方法
        Set<Map.Entry<String, String>> entrySet = map.entrySet();
        for (Map.Entry<String, String> stringStringEntry : entrySet) {
            String key = stringStringEntry.getKey();
            String value = stringStringEntry.getValue();
            System.out.println(key + "=========" + value);
        }


    }
}
